package com.multicampus.simplewiki.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.multicampus.simplewiki.model.User;

public class UserValidator implements Validator  {

	public boolean supports(Class candidate) {
		return User.class.isAssignableFrom(candidate);
	}

	public void validate(Object arg0, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "id", "required", "Id is required.");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "required", "name is required.");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "required", "password is required.");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "confirm", "required", "confirm is required.");
	}

}
